{template 'common/header'}
<div class="main">
    <ul class="nav nav-tabs">
        <li {if ($op=='display' || !$op)}class="active"{/if}><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'display'));}">档期概况</a></li>
        <li {if $op == 'list'}class="active"{/if}><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'list'));}">档期列表</a></li>
<li {if (empty($id) && $op=='edit')}class="active"{/if}><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'edit'));}">新增档期</a></li>

        {if $just_do == 1}
        <li {if (empty($id) && $op=='edit')}class="active"{/if}><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'edit'));}">新增档期</a></li>
        {if (!empty($id) && $op=='edit')}
		<li class="active"><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'edit', 'id'=>$id));}">修改排期</a></li>
		{/if}
		<li  {if ($op=='record')}class="active"{/if}><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'record'));}">操作记录</a></li>
        {/if}
    </ul>
    
    {if $op == 'edit'}
    <div class="main">
		<form id="form" class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
			<div class="panel panel-default">
				<div class="panel-heading">排期</div>
				<div class="panel-body">
				
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">日期</label>
						<div class="col-xs-12 col-sm-8">
							{php echo tpl_form_field_date('actime', date("Y-m-d",$actime))}
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">标题</label>
						<div class="col-xs-12 col-sm-8">
							<input type="text" name="rows[title]" id="rows[title]" class="form-control" value="{$list['title']}"/>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">类型</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[type]" id="fee-type">
							 	<option value=''>请选择</option>
								{loop $typearray $k=>$v}
			                        <option value="{$k}" {if $row['type']== $k }selected="selected"{/if}>{$v}</option>
		                    	{/loop}
		                    </select>
						</div>
					</div>
					
					<div class="form-group ext-fee" style="display:none;">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">费用</label>
						<div class="col-xs-12 col-sm-8">
							<input type="text" name="rows[fee]" id="rows[fee]" class="form-control" value="{$list['fee']}"/>
						</div>
					</div>
			
					<div class="form-group ext-fee" style="display:none;">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开票</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="rows[isbill]" value="1" {if $list[isbill] == 1}checked{/if}>是</label>
							<label class="radio-inline"><input type="radio" name="rows[isbill]" value="2" {if $list[isbill] == 2}checked{/if}>否</label>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">位置</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[rank]">
							 	<option value=''>请选择</option>
								{loop $rankarray $k=>$v}
			                        <option value="{$k}" {if $rank== $k }selected="selected"{/if}>{$v}</option>
			                    {/loop}
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">内容对接</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[content_people]">
							 	<option value=''>请选择</option>
								{loop $content_people_array $k=>$v}
			                        <option value="{$v}" {if $list['content_people'] == $v }selected="selected"{/if}>{$v}</option>
			                    {/loop}
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商务对接</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[business_people]">
							 	<option value=''>请选择</option>
								{loop $business_people_array $k=>$v}
			                        <option value="{$v}" {if $list['business_people']== $v }selected="selected"{/if}>{$v}</option>
			                    {/loop}
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">备注</label>
						<div class="col-xs-12 col-sm-8">
							<textarea name="rows[remark]" id="rows[remark]" class="form-control">{$list['remark']}</textarea>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">状态</label>
						<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
							<label class="radio-inline">
								<input type="radio" name="rows[status]" value="0" {if $row['status'] == '0' || !$row['status']}checked{/if}> 已确定
							</label>
							<label class="radio-inline">
								<input type="radio" name="rows[status]" value="1" {if $row['status'] == '1'}checked{/if}> 预订位置
							</label>
						</div>
					</div>
	
					<div class="form-group">
						<div class="col-xs-12 col-sm-9 col-md-10 col-lg-10 col-sm-offset-3 col-md-offset-2 col-lg-offset-2">
							<input type="hidden" name="id" value="{$list['id']}" />
							<input name="submit" type="submit" value="提交" class="btn btn-primary" />
							<input type="hidden" name="token" value="{$_W['token']}" />
						</div>
					</div>
					
				</div>
			</div>
		</form>
	</div>

	<script>
	require(['jquery', 'util'], function($, util) {
		$(function() {
			$('#fee-type').on('change', function() {
				var type = $('#fee-type option:selected').val();
				if(type == 1 || type == 4) {
					$('.ext-fee').show();
				} else {
					$('.ext-fee').hide();
				}
			})
		
			$('#form').submit(function() {
				var type = $('#fee-type option:selected').val();
				
				if($('input[name="rows[title]"]').val() == ''){
					util.message('请填写标题');
					return false;
				}
				
				if($('select[name="rows[type]"] option:selected').val() == ''){
					util.message('请选择类型');
					return false;
				}
				
				if($('select[name="rows[rank]"] option:selected').val() == ''){
					util.message('请选择位置');
					return false;
				}
				
				if(type == 1 || type == 4) {
					if($('input[name="rows[fee]"]').val() == '' ){
						util.message('请填写费用');
						return false;
					}
					
					if($('input:radio[name="rows[isbill]"]:checked').val() == '' ){
						util.message('请选择是否开票');
						return false;
					}
				}
				
				return true;
			});
			
		});
	});
	</script>
	
	{else if $op == 'detail'}
	
	<div class="form-horizontal form">
	<div class="panel panel-default">
		<div class="panel-heading">
			详情
		</div>
		<div class="panel-body">
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">日期</label>
				<div class="col-sm-10">
					<span class="help-block">{php echo date("Y-m-d",$row['actime'])}</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">标题</label>
				<div class="col-sm-10">
					<span class="help-block">{$row[title]}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">类型</label>
				<div class="col-sm-10">
					<span class="help-block">{$typearray[$row['type']]}</span>
				</div>
			</div>
			
			{if ($row[type] == '1' || $row[type] == '4') && $row[fee] != ''}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">费用</label>
				<div class="col-sm-10">
					<span class="help-block">{$row[fee]}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开票</label>
				<div class="col-sm-10">
					<span class="help-block">
					{if $row['isbill'] == 1}
						是
					{else if $row['isbill'] == 2}
						否
					{else}
						/
					{/if}
					</span>
				</div>
			</div>
			{/if}
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">位置</label>
				<div class="col-sm-10">
					<span class="help-block"> {$rankarray[$row['rank']]}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">内容对接</label>
				<div class="col-sm-10">
					<span class="help-block">{if $row[content_people]}{$row[content_people]}{else}无{/if}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">商务对接</label>
				<div class="col-sm-10">
					<span class="help-block">{if $row[business_people]}{$row[business_people]}{else}无{/if}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">备注</label>
				<div class="col-sm-10">
					<span class="help-block">{if $row[remark]}{$row[remark]}{else}无{/if}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
				<div class="col-sm-10">
					<span class="help-block">{if $row[status]}<span style="color:red;">预定占位</span>{else}正常{/if}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加时间</label>
				<div class="col-sm-10">
					<span class="help-block">{php echo date("Y-m-d H:i:s",$row['addtime'])}</span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加人员</label>
				<div class="col-sm-10">
					<span class="help-block">{$row[realname]}</span>
				</div>
			</div>
			
			{if $row['altertime']}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">最后修改时间</label>
				<div class="col-sm-10">
					<span class="help-block">{php echo date("Y-m-d H:i:s",$row['altertime'])}</span>
				</div>
			</div>
			{/if}
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
				<div class="col-sm-10">
					<span class="help-block">
					<a href="javascript:history.go(-1);" class="btn btn-primary">返回</a>
                        {if $just_do == 1}
					<a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'edit','id'=>$row['id']));}" class="btn btn-default" data-original-title="修改" title="">修改</a>
					<a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'delete','id'=>$row['id']));}" onclick="if(!confirm('删除后将不可恢复,确定删除吗?')) return false;" class="btn btn-default" data-original-title="查看图片" title="">删除</a>
					{/if}
					
					</span>
				</div>
			</div>
		</div>
	</div>
</div>

	{else if $op == 'record'}
    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover" style="position: relative">
                <thead class="navbar-inner">
                    <tr>
                        <th width="100">序号</th>
                        <th width="200">账号</th>
						<th width="100">操作ID</th>
						<th width="200">操作时间</th>
						<th width="150">操作类型</th>
						<th>操作内容</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td>{$row['id']}</td>
                        <td>{$row['username']}</td>
						<td>{$row['uid']}</td>
                        <td>{php echo date("Y-m-d H:i:s",$row['addtime'])}</td>
                        <td>{$doarray[$row['type']]}</td>
                        <td>{$row['actitle']}</td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
        </div>
    </div>
    {$pager}

    {else if $op == 'list'}

    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site">
                <input type="hidden" name="a" value="entry">
                <input type="hidden" name="m" value="knbsys_schedule">
                <input type="hidden" name="do" value="Acmanage">
                <input type="hidden" name="op" value="list">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">选择时间</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">{php echo tpl_form_field_daterange('l_birth', $l_birth);}</div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排期类型</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <select  class="form-control" name="l_type">
                            <option value=''>请选择</option>
                            {loop $typearray $k=>$v}
                            <option value="{$k}" {if $l_type == $k }selected="selected"{/if}>{$v}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排期标题</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_title" value="{$l_title}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">内容对接</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_content_people" value="{$l_content_people}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商务对接</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_business_people" value="{$l_business_people}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="pull-right col-xs-12 col-sm-3 col-md-2 col-lg-2">
                        <button class="btn btn-default" data-original-title="" title=""><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover" style="position: relative">
                <thead class="navbar-inner">
                <tr>
                    <th width="100">序号</th>
                    <th width="200">标题</th>
                    <th width="100">档期时间</th>
                    <th width="60">类型</th>
                    <th width="80">费用</th>
                    <th width="100">是否开票</th>
                    <th width="100">位置</th>
                    <th width="100">内容对接</th>
                    <th width="100">商务对接</th>
                    <th width="200">添加时间</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$row['title']}</td>
                    <td>{php echo date("Y-m-d",$row['actime'])}</td>
                    <td>{$typearray[$row['type']]}</td>
                    <td>{if $row['fee']}{$row['fee']}{else}/{/if}</td>
                    <td>{if $row['isbill'] == 1}是{else if $row['isbill'] == 2}否{else}/{/if}</td>
                    <td>{$rankarray[$row['rank']]}</td>
                    <td>{$row['content_people']}</td>
                    <td>{$row['business_people']}</td>
                    <td>{php echo date("Y-m-d H:i:s",$row['addtime'])}</td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
    </div>
    {$pager}

    {else}
    <div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site">
				<input type="hidden" name="a" value="entry">
				<input type="hidden" name="m" value="knbsys_schedule">
				<input type="hidden" name="do" value="Acmanage">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">选择时间</label>
					<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">{php echo tpl_form_field_daterange('birth', $birth);}</div>
				</div>
				<div class="form-group">
				<div class="pull-right col-xs-12 col-sm-3 col-md-2 col-lg-2">
					<button class="btn btn-default" data-original-title="" title=""><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
			</form>
		</div>
	</div>
   <style>
	.tbd_show td{padding:0 !important;}
	.tbd_show ul{list-style-type: none;padding:0; width:100%;margin:0;}
	.tbd_show li{text-align:left;width:100%;height:40px;line-height:40px;border-bottom:1px solid #eee;}
	.tbd_show a{display:block;width:100%;height:100%}
	.tbd_show a:hover{background-color:#fff}
	.data-list th, .data-list li { text-align:center; }
    </style>
    {php for($n=0;$n<$pai;$n++){}
    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover data-list" style="position: relative">
                <thead class="navbar-inner">
                    <tr>
                        <th width="50" style="text-align:center;">类别</th>
                        {php for($m=0;$m<7;$m++){}
                        {php $nm = ($n*7)+$m}
						<th style="text-align:center;">周{$weekarray_show[$m]}（{$acday[$nm]}）</th>
						{php }}
                    </tr>
                </thead>
                <tbody class="tbd_show">
                    <tr>
                        <td width="9%">
                        	<ul>
                        		<li>头条</li>
                        		<li>次一</li>
                        		<li>次二</li>
                        		<li>次三</li>
                        		<li>次四</li>
                        	</ul>
                        </td>
                        
                        {php for($r=0;$r<7;$r++){}
                        {php $nr = ($n*7)+$r}
                        <td width="13%">
                        	<ul>
                        		{php for($s=1;$s<6;$s++){}

                                    {if $just_do == 1}
                                        {if $acrows[$nr][$s]}
                                        <li><a {if $red[$nr][$s]}style="color:red;"{/if} data-toggle="popover" rel="popover" data-content="标题：{$acrows[$nr][$s]}<br />类型：{$typearray[$actypes[$nr][$s]]}<br />商务对接：{if $swdj[$nr][$s]}{$swdj[$nr][$s]}{else}无{/if}<br />内容对接：{if $nrdj[$nr][$s]}{$nrdj[$nr][$s]}{else}无{/if}<br />" data-original-title="{$acrows[$nr][$s]}" href="{php echo $this->createWebUrl('Acmanage', array('op'=>'detail','actime'=>$actime[$nr],'rank'=>$s));}"> [{$typearray[$actypes[$nr][$s]]}] {$acrows[$nr][$s]}</a></li>
                                        {else}
                                        <li><a href="{php echo $this->createWebUrl('Acmanage', array('op'=>'edit','actime'=>$actime[$nr],'rank'=>$s));}"></a></li>
                                        {/if}
                                    {else}
                                        {if $acrows[$nr][$s]}
                                        <li><a {if $red[$nr][$s]}style="color:red;"{/if} data-toggle="popover" rel="popover" data-content="标题：{$acrows[$nr][$s]}<br />类型：{$typearray[$actypes[$nr][$s]]}<br />商务对接：{if $swdj[$nr][$s]}{$swdj[$nr][$s]}{else}无{/if}<br />内容对接：{if $nrdj[$nr][$s]}{$nrdj[$nr][$s]}{else}无{/if}<br />" data-original-title="{$acrows[$nr][$s]}" href="{php echo $this->createWebUrl('Acmanage', array('op'=>'detail','actime'=>$actime[$nr],'rank'=>$s));}"> [{$typearray[$actypes[$nr][$s]]}] {$acrows[$nr][$s]}</a></li>
                                        {else}
                                        <li><a href="#"></a></li>
                                        {/if}
                                    {/if}
                        		{php }}
                        	</ul>
                        </td>
                        {php }}
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    {php }}
    {/if}

    <script>
        require(['bootstrap'], function(){

            $('[data-toggle="popover"]').popover({
                "html": true,
                "trigger": "hover"
            });
			
        });
    </script>
</div>
    {template 'common/footer'}
